Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: vcs.git.backend tests #9507

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

indrajithi
Copy link
Contributor

@indrajithi indrajithi commented Jun 20, 2024

Pull Request Check List

Relates-to: #3155

  • Added tests for poetry.vcs.git.backend (increased coverage from 30% to 51%)

@indrajithi indrajithi changed the title Feature/vcs backend tests Test/vcs backend tests Jun 20, 2024
@indrajithi indrajithi changed the title Test/vcs backend tests Test: vcs.git.backend tests Jun 20, 2024
@indrajithi indrajithi marked this pull request as ready for review June 20, 2024 08:18
Copy link
Member

@radoering radoering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See suggestions.

PS: Please do not use "Resolves" for a permanent issue (because it will be closed automatically if your PR is merged). I changed it to "Relates-to".

tests/vcs/git/test_backend.py Outdated Show resolved Hide resolved
tests/vcs/git/test_backend.py Outdated Show resolved Hide resolved
tests/vcs/git/test_backend.py Outdated Show resolved Hide resolved
Comment on lines 139 to 173
def test_git_ref_spec_resolve_branch(fetch_pack_result: FetchPackResult) -> None:
mock_fetch_pack_result = fetch_pack_result

refspec = GitRefSpec(branch="main")
refspec.resolve(mock_fetch_pack_result)

assert refspec.ref == b"refs/heads/main"
assert refspec.branch == "main"
assert refspec.revision is None
assert refspec.tag is None


def test_git_ref_spec_resolve_tag(fetch_pack_result: FetchPackResult) -> None:
mock_fetch_pack_result = fetch_pack_result

refspec = GitRefSpec(revision="v1.0.0")
refspec.resolve(mock_fetch_pack_result)

assert refspec.ref == annotated_tag(b"refs/tags/v1.0.0")
assert refspec.branch is None
assert refspec.revision is None
assert refspec.tag == "v1.0.0"


def test_git_ref_spec_resolve_sha(fetch_pack_result: FetchPackResult) -> None:
mock_fetch_pack_result = fetch_pack_result

refspec = GitRefSpec(revision="abc")

refspec.resolve(mock_fetch_pack_result)

assert refspec.ref == b"refs/heads/main"
assert refspec.branch is None
assert refspec.tag is None
assert refspec.revision == "abc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we merge these three ref_spec_resolve tests into one parameterized test?

There are still some uncovered branches in _normalise, e.g. specifying a branch as revision, which can be covered easily. If we add more test variants, a parameterized tests will make even more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants